package entry59.ref;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.junit.Test;

class StackEmptyException extends RuntimeException {
	private static final long serialVersionUID = 6725532833360115886L;
}

public class CheckException {
	class Stack<E> {
		private List<E> list = new ArrayList<E>();

		public void push(E e) {
			list.add(e);
		}

		public E pop() throws StackEmptyException {
			if (list.isEmpty()) {
				throw new StackEmptyException();
			}

			return list.remove(list.size() - 1);
		}

		public boolean isEmpty() {
			return list.isEmpty();
		}
	}

@Test
public void testCheckException() {
	Stack<String> stack = new Stack<String>();
	stack.push("test");

	if (!stack.isEmpty()) {
		assertThat(stack.pop(), is("test"));
	}
}
}
